﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;

namespace DAL
{
	public class KHAMBENHDAO:DALBase
	{
		public KHAMBENHDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPKHAMBENH"; }
			set { _SpName = value; }
		}
		public DataTable GetListKB(KHAMBENH kb)
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 0));
				return dt;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public List<KHAMBENH> GetListKBS(KHAMBENH kb)
		{
			dt = new DataTable();
			List<KHAMBENH> ds = new List<KHAMBENH>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 0));
				ds = (List<KHAMBENH>)ConvertDatatableToList.ConvertTo<KHAMBENH>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public DataTable GetListKBTB(KHAMBENH kb)
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 4));
				return dt;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public List<DANHSACHCONGVIEC> GETDSCV(KHAMBENH kb)
		{
			dt = new DataTable();
			List<DANHSACHCONGVIEC> ds = new List<DANHSACHCONGVIEC>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 5));
				ds = (List<DANHSACHCONGVIEC>)ConvertDatatableToList.ConvertTo<DANHSACHCONGVIEC>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public List<DOTKHAM> GETLISTDK(DOTKHAM kb)
		{
			dt = new DataTable();
			List<DOTKHAM> ds = new List<DOTKHAM>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 8));
				ds = (List<DOTKHAM>)ConvertDatatableToList.ConvertTo<DOTKHAM>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public KHAMBENH GETKHAMBENH(KHAMBENH kb)
		{
			dt = new DataTable();
			KHAMBENH ds = new KHAMBENH();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 6));
				ds = (KHAMBENH)ConvertDatatableToList.ConvertToObject<KHAMBENH>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		//Lay cac dich vu cua mot dot kham cua mot benh nhan (TENDICHVU, DONGIA, SOLUONG, THANHTIEN)
		public DataTable GetDVof1DK(KHAMBENH kb)
		{
			dt = new DataTable();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 9));
				return dt;
			}
			catch { return null; }
		}
		public KHAMBENH GETKB(KHAMBENH kb)
		{
			dt = new DataTable();
			KHAMBENH ds = new KHAMBENH();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 11));
				ds = (KHAMBENH)ConvertDatatableToList.ConvertToObject<KHAMBENH>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public KHAMBENH GETKBONE(KHAMBENH kb)
		{
			dt = new DataTable();
			KHAMBENH ds = new KHAMBENH();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(kb, null), ConvertClassToArray.GetValues(kb, 12));
				ds = (KHAMBENH)ConvertDatatableToList.ConvertToObject<KHAMBENH>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
	}
}